
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {

  entry: path.join(__dirname, 'src', 'index'),
  
  output: {
    filename: 'app.js',
    path: path.resolve(__dirname, 'dist')
  },
  
  module: {
    rules: [
      {
        test: /\.css$/,
        include: [
          path.resolve(__dirname, 'src')
        ],
        exclude: [
          path.resolve(__dirname, 'node_modules'),
          path.resolve(__dirname, 'bower_components')
        ],
        loader: 'style-loader!css-loader'
      },
      {
        test: /\.(scss|sass)$/,
        include: [
          path.resolve(__dirname, 'src')
        ],
        exclude: [
          path.resolve(__dirname, 'node_modules'),
          path.resolve(__dirname, 'bower_components')
        ],
        loader: 'style-loader!css-loader!sass-loader'
      },      
      {
        test: /.js$/,
        include: [
          path.resolve(__dirname, 'src')
        ],
        exclude: [
          path.resolve(__dirname, 'node_modules'),
          path.resolve(__dirname, 'bower_components')
        ],
        loader: 'babel-loader'
      },
      {
        test: /\.vue$/,
        include: [
          path.resolve(__dirname, 'src')
        ],
        exclude: [
          path.resolve(__dirname, 'node_modules'),
          path.resolve(__dirname, 'bower_components')
        ],
        loader: 'vue-loader'
      }      
    ]
  },

  resolve: {
    extensions: ['.json', '.js', '.vue', '.css'],
    alias: {
      'vue': 'vue/dist/vue.js',
    }    
  },

  devtool: 'source-map',

  devServer: {
    //这个有什么作用还要详细了解
    //publicPath: path.join('/dist/'),

    //内容目录路径
    contentBase: path.join('dist'),
    //服务器端口
    port: 1111,
    //文件修改自动刷新浏览器
    inline: true
  },

  //插件
  plugins: [
    //html整合插件，负责生成包含目标js文件的html文件
    new HtmlWebpackPlugin({
        template: "src/index.html",
        filename: "index.html"
    })
  ]
};